package com.victualler.core.common.web;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Author: guoshichang
 * @Date: Create in 23:16 2018-05-06
 * @Discription:
 */
@Controller
@RequestMapping("/show")
public class ShowController {
	/**
	 * 根据不同请求请求主页内容
	 * @param model
	 * @param childModel
	 * @param function
	 * @param reqModel
	 * @return
	 */
    @RequestMapping("/{model}/{childModel}/{function}")
    public String toIndex(@PathVariable("model") String model,@PathVariable("childModel") String childModel,@PathVariable("function") String function,Model reqModel){
        return "web/"+model+"/"+childModel+"/"+function;
    }

    /**
     * 根据内容页的加载请求找到对应的页面
     * @param model
     * @param childModel
     * @param function
     * @return
     */
    @RequestMapping("/page/{model}/{childModel}/{function}")
    public String toContentPage(@PathVariable("model") String model,@PathVariable("childModel") String childModel,@PathVariable("function") String function){
        //根据参数寻找对应的页面
        return "web/"+model+"/"+childModel+"/"+function;
    }
    /**
     * 匹配通用的模块页面
     * @param function
     * @return
     */
    @RequestMapping("/page/common/{function}")
    public String toCommonPage(@PathVariable("function") String function){
        //根据参数寻找对应的页面
        return "web/common/"+function;
    }
}
